//
let lj_zq;
//
( function( global, factory ) {

    "use strict";

    if ( typeof module === "object" && typeof module.exports === "object" ) {
        module.exports = global.document ? factory( global, true ) : function( w ) {
            if ( !w.document ) {
                throw new Error( "abcdefg" );
            }
            return factory( w );
        }
    } else {
        factory( global );
    }

})( typeof window !== "undefined" ? window : this, function( window, noGlobal ) {

    " use strict ";
    //--- console.log
    function log () {
        console.log.apply( null, arguments );
    }
    //--- console.log
    var arr = [];

    var document = window.document;

    var getProto = Object.getPrototypeOf;
    
    var slice = arr.slice;

    var concat = arr.concat;

    var push = arr.push;

    var indexOf = arr.indexOf;

    var class2type = {};

    var toString = class2type.toString;

    var hasOwn = class2type.hasOwnProperty;

    var fnToString = hasOwn.toString;
    
    var ObjectFunctionString = fnToString.call( Object );

    var support = {};
    //--- isFunction
    var isFunction = function isFunction( obj ) {
        return typeof obj === "function" && typeof obj.nodeType !== "number";
    };
    //--- isWindow
    var isWindow = function( obj ) {
        return obj != null && obj === obj.window;
    };
    //--- isArray
    function isArrayLike( obj ) {
        var length = ( !!obj && "length" in obj ) && obj.length,
            type = toType( obj );
        if ( isFunction( obj ) || isWindow( obj ) ) {
            return false;
        }
        return toType === "array" || length === 0 || typeof length === "number" && length > 0 && ( length -1 ) in obj;
    }
    //
    var preservedScriptAttributes = {
        type: true,
        src: true,
        noModule: true
    };
    //
    function DOMEval( code, doc, node) {
        doc = doc || document;

        var i,
            script = doc.createElement( "script" );

        script.text = code;

        if ( node ) {
            for ( i in preservedScriptAttributes ) {
                if ( node[ i ] ) {
                    script[ i ] = node[ i ];
                }
            }
        }
        doc.head.appendChild( script ).parentNode.removeChild( script );
    }
    //
    function toType( obj ) {
        if ( obj == null ) {
            return obj + "";
        }

        return typeof obj === "object" || typeof obj === "function" ? class2type[ toString.call( obj ) ] || "object" : typeof obj;

    }
    
    //----   real start
    var version = "0.0.0";
   
    //---去首尾空格
    var rtrim = /^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g;
    //---构造函数
    lj_zq = function ( selector, context ) {
            
        return new lj_zq.fn.init( selector, context );
    }, 
    //---
    lj_zq.fn = lj_zq.prototype = {

        lj_zq: version,

        constructor: lj_zq,

        length: 0,
        //--- 
        toArray: function() {
            return slice.call( this );
        },
        //--- 
        get: function( num ) {
            if ( num == null ) {
                return slice.call( this );
            }

            return num < 0 ? this[ num + this.length ] : this[ num ];
        },
        //---
        pushStack: function( elems ) {
            var ret = lj_zq.merge( this.constructor(), elems );

            ret.prevObject = this;

            return ret;
        },
        //---
        each: function( callback ) {
            return lj_zq.each( this, callback );
        },
        //---
        map: function( callback ) {
            return this.pushStack( lj_zq.map( this, function( elem, i ) {
                return callback.call( elem, i, elem );
            } ) );
        },
        //--- 
        slice: function() {
            return this.pushStack( slice.apply( this, arguments ) );
        },
        //---
        first: function() {
            return this.eq( 0 );
        },
        //---
        last: function() {
            return this.eq( -1 );
        },
        //---
        eq: function( i ) {
            var len = this.length,
                j = +i + ( i < 0 ? len : 0 );
            return this.pushStack( j >= 0 && j < len ? [ this[ j ] ] : [] );
        },
        //---
        end: function() {
            return this.prevObject || this.constructor();
        },
        //---
        push: push,
        //---
        sort: arr.sort,
        //---
        splice: arr.splice
    };

    //--- extend合并对象
    lj_zq.extend = lj_zq.fn.extend = function() {
        var options, name, src, copy, copyIsArray, clone, 
        target = arguments[ 0 ] || {},
        i = 1,
        length = arguments.length,
        deep = false;

        //--- extend(true||false,{},{}...)
        if ( typeof target === "boolean" ) {
            deep = target;

            target = arguments[ i ] || {};

            i++;
        }

        //--- 第1个参数是bool值，target不是{}时
        if ( typeof target !== "object" && !isFunction( target ) ) {
            target = {};
        }

        //--- 只有1个参数对象时，添加到lj_zq上
        if ( i === length ) {
            target = this;
            i--;
        }

        //---
        for ( ; i < length; i++) {
            
            if ( ( options = arguments[ i ] ) != null ) {

                for ( name in options ) {
                    src = target[ name ],
                    copy = options[ name ];

                    if ( target === copy ) {
                        continue;
                    }

                    //--- 深复制
                    if ( deep && copy && ( lj_zq.isPlainObject( copy )  || ( copyIsArray = Array.isArray( copy ) ) ) ) {
                        if ( copyIsArray ) {
                            copyIsArray = false;
                            clone = src && Array.isArray( src ) ? src : [];
                        } else {
                            clone = src && lj_zq.isPlainObject( src ) ? src : {};
                        }

                        target[ name ] = lj_zq.extend( deep, clone, copy );
                    } else if ( copy !== undefined ) {
                        target[ name ] = copy;
                    } 
                }
            }
        }

        return target;
    };
    //---
    lj_zq.extend( {
        //---引入每个页面时的标记字符
        expando: "lj_zq" + ( version + Math.random() ).replace( /\D/, "" ),

        //---
        isReady: true,

        //---
        error: function( msg ){
            throw new Error( msg );
        },

        //--- 
        noop: function(){},

        //--- 是{}->object
        isPlainObject: function( obj ) {
            var proto, Ctor;
            if ( !obj || toString.call( obj ) !== "[object Object]" ){
                return false;
            }
            proto = getProto( obj );
            //--- 没有原型 Object.create(null)
            if ( !proto ) {
                return true;
            }
            Ctor = hasOwn.call( proto, "constructor" ) && proto.constructor;
            return typeof Ctor === "function" && fnToString.call( Ctor ) === ObjectFunctionString;
        },

        //--- 是空{}
        isEmptyObject: function( obj ) {
            var name;
            for ( name in obj) {
                return false;
            }
            return true;
        },

        //--- script-eval
        globalEval: function( code ) {
            DOMEval( code );
        },

        //--- each方法
        each: function( obj, callback ) {
            var length, i = 0;

            if ( isArrayLike( obj ) ) {
                length = obj.length;
                for ( ; i < length; i++ ) {
                    if ( callback.call( obj[ i ], i, obj[ i ] ) === false ) {
                        break;
                    }
                }
            } else {
                for ( i in obj ) {
                    if ( callback.call( obj[ i ], i, obj[ i ] ) === false ) {
                        break;
                    }
                }
            }
        },

        //--- 去字符串空格
        trim: function( text ) {
            return text == null ? "" : ( text + "" ).replace( rtrim, "" );
        },

        //--- 将参数转换成数组
        makeArray: function( arr, results ) {
            var ret = results || [];
            if ( arr != null ) {
                if ( isArrayLike( Object( arr ) ) ) {
                    lj_zq.merge( ret, typeof arr === "string" ? [ arr ] : arr );
                } else {
                    push.call( ret, arr );
                }
            }

            return ret;
        },

        //--- 数组合并(把second合并到first)
        merge: function( first, second ) {
            var len = +second.length,
                j = 0,
                i = first.length;
            for ( ; j < len; j++) {
                first[ i++ ] = second[ j ];
            }

            first.length = i;

            return first;
        },

        //--- 获取数组项的下标
        inArray: function( elem, arr, i ) {
            return arr == null ? -1 : indexOf.call( arr, elem, i );
        },

        //--- 数组过滤
        grep: function( elems, callback, invert ) {
            var callbackInverse,
                matches = [],
                i = 0,
                length = elems.length,
                callbackExpect = !invert;
            
            for ( ; i < length; i++ ) {
                callbackInverse = !callback( elems[ i ], i);
                if ( callbackInverse !== callbackExpect ) {
                    matches.push( elems[ i ] );
                }
            }

            return matches;
        },

        //--- 获取集合项的映射
        map: function( elems, callback, arg ) {
            var length, value,
                i = 0,
                ret = [];

            if ( isArrayLike( elems ) ) {
                length = elems.length;
                for ( ; i < length; i++ ) {
                    value = callback( elems[ i ], i, arg);

                    if ( value != null ) {
                        ret.push( value );
                    }
                }
            } else {
                for ( i in elems ) {
                    value = callback( elems[ i ], i, arg );

                    if ( value != null ) {
                        ret.push( value );
                    }
                }
            }

            return concat.apply( [], ret );
        },

        //--- 
        guid: 1,

        //---
        support: support
    } );
    //---
    if ( typeof Symbol === "function" ) {
        lj_zq.fn[ Symbol.iterator ] = arr[ Symbol.iterator ];
    }
    //--- 存数据类型字段
    lj_zq.each( "Boolean Number String Function Array Date RegExp Object Error Symbol".split( " " ), function( i, name ) {
        class2type[ "[object " + name + "]" ] = name.toLowerCase();
    } );
    //
    
    //
//------------------------------  Sizzle -S
/* 
*Sizzle CSS Selector
*/
var Sizzle = 
(function( window) {
    var i,
        support,
        Expr,
        getText,
        isXML,
        tokenize,
        compile,
        select,
        outermostContext,
        sortInput,
        hasDuplicate,
        //
        setDocument,
        document,
        docElem,
        documentIsHTML,
        rbuggyQSA,
        rbuggyMatches,
        matches,
        contains;
    //
    var expando = "sizzle" + 1 * new Date(),
        preferredDoc = window.document,
        dirruns = 0,
        done = 0,
        classCache = createCache(),
        tokenCache = createCache(),
        compilerCache = createCache(),
        sortOrder = function( a, b ) {
            if ( a === b ) {
                hasDuplicate = true;
            }
            return 0;
        },

        //
        hasOwn = ({}).hasOwnProperty,
        arr = [],
        pop = arr.pop,
        push_native = arr.push,
        push = arr.push,
        slice = arr.slice,
        //
        indexOf = function( list, elem ) {
            var i = 0,
                length = list.length;
            for ( ; i < length; i++ ) {
                if ( list[i] === elem ) {
                    return i;
                }
            }
            return -1;
        },
        //--- 
        booleans = "checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped";
    //
    //Regular expressions
    /* 
        * 各种空格
        *\x20-\x7E表示一系列ascii字符，其中\x20(空格)是范围的开头，\x7E(~)是结束。它基本上是任何不是字母、数字或普通标点符号的东西。
        *\t 的意思是 ：水平制表符。将当前位置移到下一个tab位置。 
        *\r 的意思是： 回车。将当前位置移到本行的开头。 
        *\n 的意思是：回车换行。将当前位置移到下一行的开头。 
        *\f 的意思是：换页。将当前位置移到下一页的开头。
    */
    var whitespace = "[\\x20\\t\\r\\n\\f]";
    /* 
    *  标识符
    *  \\\\”四个反斜杠就表示“\\”两个反斜杠字符串
    */ 
    var identifier = "(?:\\\\.|[\\w-]|[^\0-\\xa0])+";
    /* 
    * 
    */
    var attributes = "\\[" + whitespace + "*(" + identifier + ")(?:" + whitespace + "*([*^$|!~]?=)" + whitespace + "*(?:'((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\"|(" + identifier + "))|)" + whitespace + "*\\]";
    //
    //var tr = new RegExp(attributes);
    console.log(attributes.length);
    console.log(attributes2.length);
    
/* 
* createCache
*/
function createCache() {
    var keys = [];

    function cache( key, value ) {

        if ( keys.push( key + " " ) > Expr.cacheLength ) {
            delete cache[ keys.shift() ];
        }
        return (cache[ key + " " ] = value);
    }
    return cache;
}

})( window );
//------------------------------  Sizzle -E

} );

export { lj_zq };